package com.ybu;

/**
 * @ProjectName: shixun
 * @Titile: Student
 * @Author: Jie
 * @Description: TODO
 */
public class Student implements Comparable<Student> {
    //javabean

    private String name;
    private int age;
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    @Override
    public int compareTo(Student o) {
        //按照学生年龄正序排序
        //this表示当前对象
        //return this.getAge()-o.getAge();
        //倒叙（o对象的年龄-this对象的年龄）
        return o.getAge()-this.getAge();
    }
}

